<template>
  <div class="box-list-container">
    <div class="box-query-form">
      <el-form :model="queryParam" label-width="auto" label-position="right" :gutter="24">
        <el-row>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="文本框:">
              <el-input v-model="queryParam.text" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="文本框:">
              <el-input v-model="queryParam.text" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="下拉框:">
              <el-select v-model="queryParam.state" clearable placeholder="请选择">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <template v-if="toggleSearchStatus">
            <el-col :xl="6" :lg="6" :md="12" :sm="24">
              <el-form-item label="检查时间:">
                <el-date-picker
                  v-model="queryParam.physicalTime"
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="请选择"
                />
              </el-form-item>
            </el-col>
          </template>
          <el-col :xl="6" :lg="6" :md="12" :sm="24" class="table-search-btn">
            <el-button icon="el-icon-refresh" @click="searchReset">重置</el-button>
            <el-button type="primary" icon="el-icon-search" @click="searchQuery">查询</el-button>
            <el-link style="margin-left: 10px;" type="primary" :underline="false" @click="toggleSearchStatus = !toggleSearchStatus">
              {{ toggleSearchStatus ? '收起' : '展开' }}
              <i :class="toggleSearchStatus ? 'el-icon-arrow-up' : 'el-icon-arrow-down'" />
            </el-link>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="box-table">
      <div class="table-title">
        <div class="table-title-left">
          通用模板列表
        </div>
        <div>
          <el-button plain class="btnAdd" icon="el-icon-plus" @click="handleAdd('新增')">新增</el-button>
          <exportExcel :url="'导出地址'" :params="queryParam" file-name="导出的文件名称" />
          <importExcel export-xls-url="模板地址" import-url="导入地址" @ok="modalFormOk" />
        </div>
      </div>
      <!-- 批量操作 -->
      <div v-if="selectedRowList.length" class="batchAction">
        <div class="batchAction-left">
          <el-dropdown>
            <el-button>
              批量操作 <i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <div @click="batchDelete"><i class="el-icon-delete" />删除</div>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
        <div class="batchAction-right">
          已选择
          <span style="font-weight: 700">
            <el-link type="primary" :underline="false">{{ selectedRowList.length }}</el-link>
          </span>项
          <el-link type="primary" :underline="false" style="margin-left: 24px;" @click="onClearSelected">清空</el-link>
        </div>
      </div>
      <el-table ref="table" :data="dataSource" @selection-change="onSelectChange">
        <el-table-column type="selection" width="55" />
        <el-table-column fixed="left" label="序号" width="100" type="index" />
        <el-table-column prop="column1" label="列1" width="120" />
        <el-table-column prop="column2" label="列2" />
        <el-table-column prop="column3" label="列3" />
        <el-table-column prop="column4" label="列4" />
        <el-table-column prop="column5" label="列5" />
        <el-table-column fixed="right" label="操作" width="300">
          <template slot-scope="scope">
            <el-button type="text" @click="handleView('查看', scope.row)">查看</el-button>
            <el-button type="text" @click="handleEdit('编辑', scope.row)">编辑</el-button>
            <el-popconfirm title="确定删除吗？" style="margin-left: 10px" @confirm="handleDelete(scope.row[guidFieldName])">
              <el-button slot="reference" type="text" style="color: red;">删除</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>
      <div class="box-paging">
        <Pagination
          v-show="ipagination.total > 0"
          layout="total, sizes, prev, pager, next"
          :total="ipagination.total"
          :page.sync="ipagination.pageNum"
          :limit.sync="ipagination.pageSize"
          @pagination="loadData"
        />
      </div>
    </div>
    <!-- 查看 -->
    <viewDrawer ref="modalFormView" />
    <!-- 编辑 -->
    <handleDrawer ref="modalForm" @ok="modalFormOk" />
  </div>
</template>

<script>
import { listMixin } from '@/mixins/listMixin'
import Pagination from '@/components/Pagination'
import viewDrawer from './components/viewDrawer'
import handleDrawer from './components/handleDrawer'
import exportExcel from '@/components/xm/exportExcel/exportExcel'
import importExcel from '@/components/xm/importExcel/importExcel'
export default {
  components: {
    Pagination,
    viewDrawer,
    exportExcel,
    importExcel,
    handleDrawer
  },
  mixins: [listMixin],
  data() {
    return {
      guidFieldName: 'id', // 唯一标识字段
      toggleSearchStatus: false,
      options: [],
      url: {
        list: 'http://124.223.214.5:200/api/TemplateTable.aspx?action=GetList',
        deleteBatch: ''
      }
    }
  },
  created() {},
  mounted() {},
  methods: {
  }
}
</script>

<style lang="scss" scoped>
</style>

